

using System;
using System.Collections.Generic;
using System.Text;

namespace JTC.MiniCommerce.Store.Services.ShippingService {
  public class SimpleWeightShippingProvider : IShippingProvider {
    
    #region IShippingProvider Members

    /// <summary>
    /// Gets the shipping options.
    /// </summary>
    /// <param name="order"></param>
    /// <returns></returns>
    public ShippingOptionCollection GetShippingOptions(Order order) {
      ShippingOptionCollection shippingOptionCollection = new ShippingOptionCollection();
      SimpleWeightShippingRateCollection simpleWeightShippingRateCollection = new SimpleWeightShippingRateController().FetchAll();
      ShippingOption shippingOption;
      foreach(SimpleWeightShippingRate simpleWeightShippingRate in simpleWeightShippingRateCollection) {
        shippingOption = new ShippingOption();
        shippingOption.Service = simpleWeightShippingRate.Service;
        shippingOption.Rate = simpleWeightShippingRate.AmountPerUnit * order.TotalWeight;
        shippingOptionCollection.Add(shippingOption);
      }
      return shippingOptionCollection;
    }

    #endregion
    
  }
}
